package com.xinqi.modules.sys.textbook.controller.app;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.sys.textbook.dto.req.CloudTextbookInfoQueryDTO;
import com.xinqi.modules.sys.textbook.dto.rsp.CloudTextbookInfoResultDTO;
import com.xinqi.modules.sys.textbook.service.CloudTextbookInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 云课本基本信息APP控制层
 *
 * @author: linkai
 * @date: 2023/04/25
 */
@Tag(name = "APP-云课本", description = "云课本App接口")
@RestController
@RequestMapping("/app/cloud-textbook")
@RequiredArgsConstructor
public class CloudTextbookInfoAppController {
    private final CloudTextbookInfoService cloudTextbookInfoService;

    /**
     * 云课本基本信息-分页
     */
    @Operation(summary = "云课本基本信息-分页")
    @GetMapping("/page")
    public R<PageInfo<CloudTextbookInfoResultDTO>> page(@ParameterObject CloudTextbookInfoQueryDTO dto) {
        PageInfo<CloudTextbookInfoResultDTO> page = cloudTextbookInfoService.page(dto, dto);
        return R.data(page);
    }

    /**
     * 云课本基本信息-详情
     */
    @Operation(summary = "云课本基本信息-详情")
    @GetMapping("/{id}")
    public R<CloudTextbookInfoResultDTO> findById(@PathVariable("id") Long id) {
        CloudTextbookInfoResultDTO dto = cloudTextbookInfoService.findById(id);
        return R.data(dto);
    }
}
